package com.aabte.design.pattern.creational.singleton;

public class ContainerSingletonTest {

    public static void main(String[] args) throws InterruptedException {

        Thread thread1 = new Thread(new T());
        Thread thread2 = new Thread(new T());

        thread1.start();
        thread2.start();

        thread1.join();
        thread2.join();

        System.out.println("program end.");

    }

    static class T implements Runnable{

        public void run() {
            String key = "object";
            ContainerSingleton.putInstance(key, new Object());
            Object instance = ContainerSingleton.getInstance(key);
            System.out.println(instance);

        }
    }

}
